package com.hzhr.iot.toll.dao;

import com.hzhr.iot.toll.dao.mapper.custom.UserGasUserEntityCustomMapper;
import com.hzhr.iot.toll.dao.mapper.generator.UserGasUserEntityMapper;
import com.hzhr.iot.toll.entity.UserGasUserEntity;
import com.hzhr.iot.toll.entity.ext.UserGasUserEntityExt;
import com.hzhr.iot.toll.queryModel.custom.UserGasUserCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class UserGasUserDao {
    @Autowired
    UserGasUserEntityMapper gasUserEntityMapper;
    @Autowired
    UserGasUserEntityCustomMapper gasUserEntityCustomMapper;

    public int insert(UserGasUserEntity record) {
        if (record == null) return 0;
        int changeCount = gasUserEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = gasUserEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(UserGasUserEntity record) {
        if (record == null) return 0;
        int changeCount = gasUserEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = gasUserEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public UserGasUserEntity selectEntity(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<UserGasUserEntityExt> extList = gasUserEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<UserGasUserEntity> selectEntityList(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<UserGasUserEntityExt> extList = gasUserEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<UserGasUserEntity> entityList = new ArrayList<>();
        for (UserGasUserEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public UserGasUserEntityExt selectExt(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<UserGasUserEntityExt> extList = gasUserEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<UserGasUserEntityExt> selectExtList(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<UserGasUserEntityExt> extList = gasUserEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public UserGasUserEntity selectBasicInfoEntity(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<UserGasUserEntityExt> extList = gasUserEntityCustomMapper.selectBasicInfoExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<UserGasUserEntity> selectBasicInfoEntityList(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<UserGasUserEntityExt> extList = gasUserEntityCustomMapper.selectBasicInfoExt(queryModel);
        if (extList == null) return null;
        List<UserGasUserEntity> entityList = new ArrayList<>();
        for (UserGasUserEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public UserGasUserEntityExt selectBasicInfoExt(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<UserGasUserEntityExt> extList = gasUserEntityCustomMapper.selectBasicInfoExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<UserGasUserEntityExt> selectBasicInfoExtList(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<UserGasUserEntityExt> extList = gasUserEntityCustomMapper.selectBasicInfoExt(queryModel);
        return extList;
    }

    public int selectCount(UserGasUserCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = gasUserEntityCustomMapper.selectCount(queryModel);
        return count;
    }
}
